package com.zqxq.lottery.entity.o2o.sys;

import com.baomidou.mybatisplus.plugins.Page;
import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.common.utils.PageCopy;
import com.zqxq.lottery.entity.po.sys.SysDiscoveryPO;
import com.zqxq.lottery.entity.vo.sys.SysDiscoveryVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2018/03/14 16:13
 */
public class SysDiscoveryO2O {
    public static SysDiscoveryVO toVO(SysDiscoveryPO po) {
        if (po == null) {
            return null;
        }
        SysDiscoveryVO sysDiscoveryVO = new SysDiscoveryVO();
        sysDiscoveryVO.setId(DispatcherUtils.parseString(po.getId()));
        sysDiscoveryVO.setTheme(po.getTheme());
        sysDiscoveryVO.setImgUrl(po.getImg_url());
        sysDiscoveryVO.setLinkUrl(po.getLink_url());
        sysDiscoveryVO.setDetails(po.getDetails());
        sysDiscoveryVO.setSort(DispatcherUtils.parseString(po.getSort()));
        sysDiscoveryVO.setStatus(DispatcherUtils.parseString(po.getStatus()));
        sysDiscoveryVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        sysDiscoveryVO.setUpdateTime(DispatcherUtils.parseDateTimeStr(po.getUpdate_time()));
        return sysDiscoveryVO;
    }
    public static Page<SysDiscoveryVO> toPageVO(Page<SysDiscoveryPO> page){
        Page<SysDiscoveryVO> result = PageCopy.copyProperty(page, null);
        if(page != null){
            List<SysDiscoveryPO> poList = page.getRecords();
            List<SysDiscoveryVO> voList = toVOList(poList);
            result.setRecords(voList);
        }
        return result;
    }
    public static SysDiscoveryPO toPO(SysDiscoveryVO vo) {
        if (vo == null) {
            return null;
        }
        SysDiscoveryPO sysDiscoveryPO = new SysDiscoveryPO();
        sysDiscoveryPO.setId(DispatcherUtils.parseLong(vo.getId()));
        sysDiscoveryPO.setTheme(vo.getTheme());
        sysDiscoveryPO.setImg_url(vo.getImgUrl());
        sysDiscoveryPO.setLink_url(vo.getLinkUrl());
        sysDiscoveryPO.setDetails(vo.getDetails());
        sysDiscoveryPO.setSort(DispatcherUtils.parseInteger(vo.getSort()));
        sysDiscoveryPO.setStatus(DispatcherUtils.parseInteger(vo.getStatus()));
        sysDiscoveryPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        sysDiscoveryPO.setUpdate_time(DispatcherUtils.parseDateTime(vo.getUpdateTime()));
        return sysDiscoveryPO;
    }

    public static List<SysDiscoveryVO> toVOList(List<SysDiscoveryPO> list){
        List<SysDiscoveryVO> result = new ArrayList();
        if(list != null && list.size() > 0){
            for (SysDiscoveryPO po : list) {
                result.add(toVO(po));
            }
        }
        return result;
    }

}
